﻿using JumpKick.HttpLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace ThreadTest
{
    sealed class Singleton
    {
        Action<string> SuccessAction ;
        Action<WebException> FailAction;
        private static readonly Singleton instance = null;
        static Singleton()
        {
            instance = new Singleton();
        }
        private Singleton()
        {
        }
        public static Singleton Instance
        {
            get
            {
                return instance;
            }
        }

        public Singleton setSuccess(Action<String> action)
        {
            SuccessAction = action;
            return Instance;
        }
        public Singleton setFail(Action<WebException> action)
        {
            FailAction = action;
            return Instance;
        }
        public void run()
        {
            if (SuccessAction == null || FailAction == null)
                throw new Exception("请先设置SuccessAction和FailAction");
            Http.Get("https://www.baidu.com").OnSuccess(SuccessAction).OnFail(FailAction).Go();
        }

    }
}
